{% set page_title = forum.title %}
{% set active_forum_nav=True %}

{% extends theme("layout.html") %}
{% block content %}
{% from theme('_macros/pagination.html') import render_pagination, topic_pages %}

<div class="forum-view">
    <ol class="breadcrumb xfree-breadcrumb bg-light">
        <li class="breadcrumb-item"><a href="{{ url_for('forum.index') }}">{% trans %}Forum{% endtrans %}</a></li>
        <li class="breadcrumb-item"><a href="{{ forum.category.url }}">{{ forum.category.title }}</a></li>
        <li class="breadcrumb-item active">{{ forum.title }}</li>
    </ol>

    <div class="row controls-row pt-0">
        <div class="col me-auto g-0">
            {{ render_pagination(topics, forum.url) }}
        </div> <!-- end span pagination -->

        {% if current_user|post_topic(forum) %}
        <div class="col-auto g-0">
            <form class="d-inline" method="post" action="{{ url_for('forum.markread', forum_id=forum.id, slug=forum.slug) }}">
                <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
                <button class="btn btn-white">
                    <span class="fas fa-check fa-fw"></span> {% trans %}Mark as Read{% endtrans %}
                </button>
            </form>

            {% if forum.locked %}
            <span class="btn btn-primary">
                <span class="fas fa-lock fa-fw"></span> {% trans %}Locked{% endtrans %}
            </span>
            {% else %}
            <a href="{{ url_for('forum.new_topic', forum_id=forum.id, slug=forum.slug) }}" class="btn btn-primary">
                <span class="fas fa-plus fa-fw"></span> {% trans %}New Topic{% endtrans %}
            </a>
            {% endif %}
        </div>
        {% endif %}
    </div>

    <div class="card forum">
        <div class="card-header forum-header">
            <a href="{{ forum.url }}">{{ forum.title }}</a>
        </div>

        <div class="card-body forum-body">
            {% include theme("forum/_forum_meta.html") %}

            {% for topic, last_post, topicread in topics.items %}
                {% include theme("forum/_forum_row.html") %}
            {% else %}
            <div class="row forum-row clearfix">
                <div class="col-12">
                    {% trans %}No Topics.{% endtrans %}
                </div>
            </div> <!-- end forum-row -->
            {% endfor %}
        </div>
    </div>

    {% if current_user|can_moderate(forum) %}
    <div class="row controls-row">
        <div class="col-auto ms-auto g-0">
        <a class="btn btn-outline-dark" href="{{ url_for('forum.manage_forum', forum_id=forum.id, slug=forum.slug) }}">
            <span class="fas fa-tasks fa-fw"></span> {% trans %}Moderation Mode{% endtrans %}
        </a>
        </div>
    </div>
    {% endif %}
</div>
{% endblock %}
